/*
 * Created by: 	Zhaoningbo
 * at:			2011-8-15 - 下午04:05:19
 * blog:		(http://zhaoningbo.iteye.com/)
 */
package com.gc.test;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Locale;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.gc.action.HelloCn;
import com.gc.action.HelloEn;
import com.gc.action.HelloWorld;
import com.gc.action.Log;

public class MyTestHelloWorld implements Serializable {

    private static final long serialVersionUID = 6508990238861720110L;

    public static void main(String[] args) {
        ApplicationContext applicationContext = new FileSystemXmlApplicationContext(
                "classpath:config.xml");

        HelloWorld helloWorld = (HelloWorld) applicationContext
                .getBean("HelloWorld");
        System.out
                .println(helloWorld.getDate() + ":" + helloWorld.getMessage());

        HelloCn helloUsingCn = (HelloCn) applicationContext.getBean("HelloCn");
        System.out.println(helloUsingCn.doSaluation("CN:"));

        HelloEn helloUsingEn = (HelloEn) applicationContext.getBean("HelloEn");
        System.out.println(helloUsingEn.doSaluation("EN:"));
        
        Object[] messageSnippet = new Object[]{"mgs-HelloWorld", Calendar.getInstance().getTime()};
        String messageCnUtf8 = applicationContext.getMessage("HelloWorld_UTF8", messageSnippet, Locale.CHINA);
        System.out.println(messageCnUtf8);
        String messageCnAscii = applicationContext.getMessage("HelloWorld_ASCII", messageSnippet, Locale.CHINA);
        System.out.println(messageCnAscii);
        String messageEn = applicationContext.getMessage("HelloWorld", messageSnippet, Locale.US);
        System.out.println(messageEn);

        Log log = (Log)applicationContext.getBean("log");
        log.log("lalala");
        
//        TimeBookInterface timeBookInterface = (TimeBookInterface)applicationContext.getBean("logProxy");
//        timeBookInterface.doAuditing("August");
        
        com.gc.impl.TimeBook timeBook = (com.gc.impl.TimeBook)applicationContext.getBean("logProxy");
        timeBook.audit("<#timeBook#>");
    }

}
